home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / fntool / writedir.c < prev    next >
Text File  |  1993-12-06  |  936b  |  34 lines

  1. #include "fntool.h"
  2. #include "../include/grx.h"
  3. #include "../include/grxfile.h"
  4.  
  5. void writedir(int argc,char **argv)
  6. {
  7.     FntDirHdr  dhdr;
  8.     FntFileHdr fhdr;
  9.     char name[100],*p;
  10.  
  11.     dhdr.magic = FONTDIR_MAGIC;
  12.     dhdr.numentries = argc;
  13.     fwrite(&dhdr,sizeof(FntDirHdr),1,outfile);
  14.     while(--argc >= 0) {
  15.         openinput(*argv++,"rb");
  16.         if(fread(&fhdr,sizeof(fhdr),1,infile) != 1)
  17.         fatalerr("error reading input file \"%s\"",inname);
  18.         if(fhdr.magic != FONT_MAGIC)
  19.         fatalerr("invalid \".fnt\" file: \"%s\"",inname);
  20.         if(opt.verbose)
  21.         printf("  adding font \"%s\" to directory \"%s\"\n",inname,outname);
  22.         strcpy(name,inname);
  23.         for(p = name; *p != '\0'; p++) {
  24.         if(*p == '\\') { *p = '/'; continue; }
  25.         *p = tolower(*p);
  26.         }
  27.         memset(fhdr.h.fnt_name,0,sizeof(fhdr.h.fnt_name));
  28.         strcpy(fhdr.h.fnt_name,name);
  29.         fwrite(&fhdr.h,sizeof(GrFont),1,outfile);
  30.         closeinput();
  31.     }
  32. }
  33.  
  34.